home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / Kubuntu 8.10 / kubuntu-8.10-desktop-i386.iso / casper / filesystem.squashfs / etc / apm / apmd_proxy
Text File  |  2008-06-19  |  4KB  |  92 lines

  1. #!/bin/sh
  2. # apmd_proxy - program dispatcher for APM daemon
  3. #
  4. # Written by Craig Markwardt (craigm@lheamail.gsfc.nasa.gov) 21 May 1999
  5. # Modified for Debian by Avery Pennarun
  6. #
  7. # This shell script is called by the APM daemon (apmd) when a power
  8. # management event occurs.  Its first and second arguments describe the
  9. # event.  For example, apmd will call "apmd_proxy suspend system" just
  10. # before the system is suspended.
  11. #
  12. # Here are the possible arguments:
  13. #
  14. # start              - APM daemon has started
  15. # stop               - APM daemon is shutting down
  16. # suspend critical   - APM system indicates critical suspend (++)
  17. # suspend system     - APM system has requested suspend mode
  18. # suspend user       - User has requested suspend mode
  19. # standby system     - APM system has requested standby mode 
  20. # standby user       - User has requested standby mode
  21. # resume suspend     - System has resumed from suspend mode
  22. # resume standby     - System has resumed from standby mode
  23. # resume critical    - System has resumed from critical suspend
  24. # change battery     - APM system reported low battery
  25. # change power       - APM system reported AC/battery change
  26. # change time        - APM system reported time change (*)
  27. # change capability  - APM system reported config. change (+)
  28. #
  29. # (*) - APM daemon may be configured to not call these sequences
  30. # (+) - Available if APM kernel supports it.
  31. # (++) - "suspend critical" is never passed to apmd from the kernel,
  32. #   so we will never see it here.  Scripts that process "resume
  33. #   critical" events need to take this into account.
  34. #
  35. # It is the proxy script's responsibility to examine the APM status
  36. # (via /proc/apm) or other status and to take appropriate actions.
  37. # For example, the script might unmount network drives before the
  38. # machine is suspended.
  39. #
  40. # In Debian, the usual way of adding functionality to the proxy is to
  41. # add a script to /etc/apm/event.d.  This script will be called by
  42. # apmd_proxy (via run-parts) with the same arguments.
  43. #
  44. # If it is important that a certain set of script be run in a certain
  45. # order on suspend and in a different order on resume, then put all
  46. # the scripts in /etc/apm/scripts.d instead of /etc/apm/event.d and
  47. # symlink to these from /etc/apm/suspend.d, /etc/apm/resume.d and
  48. # /etc/apm/other.d using names whose lexicographical order is the same
  49. # as the desired order of execution.
  50. #
  51. # If the kernel's APM driver supports it, apmd_proxy can return a non-zero
  52. # exit status on suspend and standby events, indicating that the suspend
  53. # or standby event should be rejected.
  54. #
  55. # *******************************************************************
  56.  
  57. set -e
  58.  
  59. # The following doesn't yet work, because current kernels (up to at least
  60. # 2.4.20) do not support rejection of APM events.  Supporting this would
  61. # require substantial modifications to the APM driver.  We will re-enable
  62. # this feature if the driver is ever modified.       -- cph@debian.org
  63. #
  64. #SUSPEND_ON_AC=false
  65. #[ -r /etc/apm/apmd_proxy.conf ] && . /etc/apm/apmd_proxy.conf
  66. #
  67. #if [ "${SUSPEND_ON_AC}" = "false" -a "${2}" = "system" ] \
  68. #    && on_ac_power >/dev/null; then
  69. #    # Reject system suspends and standbys if we are on AC power
  70. #    exit 1  # Reject (NOTE kernel support must be enabled)
  71. #fi
  72.  
  73. if [ "${1}" = "suspend" -o "${1}" = "standby" ]; then
  74.     run-parts --arg="${1}" --arg="${2}" /etc/apm/event.d
  75.     if [ -d /etc/apm/suspend.d ]; then
  76.         run-parts --arg="${1}" --arg="${2}" /etc/apm/suspend.d
  77.     fi
  78. elif [ "${1}" = "resume" ]; then
  79.     if [ -d /etc/apm/resume.d ]; then
  80.         run-parts --arg="${1}" --arg="${2}" /etc/apm/resume.d
  81.     fi
  82.     run-parts --arg="${1}" --arg="${2}" /etc/apm/event.d
  83. else
  84.     run-parts --arg="${1}" --arg="${2}" /etc/apm/event.d
  85.     if [ -d /etc/apm/other.d ]; then
  86.         run-parts --arg="${1}" --arg="${2}" /etc/apm/other.d
  87.     fi
  88. fi
  89.  
  90. exit 0
  91.